# -*- coding: utf-8 -*-
from db.mysql import MysqlClient
from common.helper import Helper
class Arrangement(object):
    def __init__(self):
        self.mysql = MysqlClient()
        self.name = "泰无忧·住院保（2019版）"
    def pullData(self, data={}):
        for item in Helper.selectData(self.name, self.mysql):
            data["name"] = self.name
            data["company"] = "泰康保险"
            data["year"] = item["year"]
            data["forWho"] = item["forWho"]
            data["accident_death"] = item["accident_death"]
            data["accident_medical"] = item["accident_medical"]
            data["disease_hospital"] = item["disease_hospital"]
            data["professions"] = '""' if item["professions"] == "" else "'"+item["professions"] + "'"
            data["price"] = item["price"]
            Sql = 'INSERT INTO `accident`(`name`,`company`,`year`,`forWho`,`accident_death`,`accident_medical`,`disease_hospital`,`professions`,`price`)VALUES("{name}","{company}","{year}","{forWho}","{accident_death}","{accident_medical}","{disease_hospital}",{professions},"{price}")'
            self.mysql.cursor.execute( Sql.format( **data ))
            self.mysql._conn.commit()
            print(Sql.format( **data )  )


